package com.objetdirect.gwt.umldrawer.client;

import com.gwtext.client.core.Margins;
import com.gwtext.client.core.RegionPosition;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.layout.BorderLayout;
import com.gwtext.client.widgets.layout.BorderLayoutData;
import com.gwtext.client.widgets.layout.FitLayout;
import com.gwtext.client.widgets.tree.TreePanel;

public class UMLDrawerPage {

	public Panel getUMLDrawerPage() {

		Panel panel = new Panel();
		panel.setBorder(false);
		panel.setTitle("Online Professional Design UML Drawer");
		panel.setWidth(1360);
		panel.setHeight(565);
		panel.setPaddings(0);
		panel.setCollapsible(true);
		panel.setTitleCollapse(true);
		panel.setAutoScroll(true);
		panel.setStyleName("UMLDrawer_panel");
		panel.setLayout(new FitLayout());

		Panel borderPanel = new Panel();
		borderPanel.setLayout(new BorderLayout());

		// add south panel (SVN History)
		Panel svnPanel = new Panel();
		svnPanel.setHeight(100);
		svnPanel.setCollapsible(true);
		svnPanel.setTitle("SVN History");
		svnPanel.setAutoScroll(true);

		BorderLayoutData svnData = new BorderLayoutData(RegionPosition.SOUTH);
		svnData.setMinSize(100);
		svnData.setMaxSize(200);
		svnData.setMargins(new Margins(0, 0, 0, 0));
		svnData.setSplit(true);
		borderPanel.add(svnPanel, svnData);

		// add east panel
		Panel chatPanel = new Panel();
		chatPanel.setTitle("Chatting Panel");
		chatPanel.setCollapsible(true);
		chatPanel.setWidth(225);
		chatPanel.setTitleCollapse(true);

		BorderLayoutData chatData = new BorderLayoutData(RegionPosition.EAST);
		chatData.setSplit(true);
		chatData.setMinSize(175);
		chatData.setMaxSize(400);
		chatData.setMargins(new Margins(0, 0, 5, 0));

		borderPanel.add(chatPanel, chatData);

		Panel projectPanel = new Panel();
		projectPanel.setTitle("Project Panel");
		projectPanel.setCollapsible(true);
		projectPanel.setWidth(200);
		projectPanel.setTitleCollapse(true);
		projectPanel.setAutoScroll(true);
		
		BorderLayoutData projectData = new BorderLayoutData(RegionPosition.WEST);
		projectData.setSplit(true);
		projectData.setMinSize(175);
		projectData.setMaxSize(400);
		projectData.setMargins(new Margins(0, 5, 0, 0));

		borderPanel.add(projectPanel, projectData);
		
		//Adding Tree Panel To Project Panel
		TreePanel openProject = new TreePanel() ;
		openProject.setRootNode(new OpenProjectTree().getOpenProjectTree());
		projectPanel.add(openProject);

		Panel centerPanel = new Panel();
		centerPanel.setHtml("<p>GWT UML Drawer ...</p>");

		borderPanel.add(centerPanel,
				new BorderLayoutData(RegionPosition.CENTER));

		panel.add(borderPanel);

		return panel ;
	}
}
